# controller.py
from view import TimeView
from time_model import TimeModel

class TimeController:
    def __init__(self):
        self.view = TimeView()
        self.model = self.view.model

        # 连接模型信号到视图更新时间标签
        self.model.running_changed.connect(self.update_time_labels)

    def start_app(self):
        self.view.show()
        self.model.set_running(True)

    def update_time_labels(self):
        for row in range(6):  # 假设每一行代表一个Frame
            index = self.model.index(row, 0)  # 获取对应索引
            time_str = self.model.currentTime
            self.view.listView.itemWidget(index).setText(time_str)

if __name__ == "__main__":
    app = QApplication([])
    controller = TimeController()
    controller.start_app()
    app.exec_()
